<!DOCTYPE html>
<html lang="zh">
<head>
    <title><{:isset($webConf.bs_title)?$webConf.bs_title:'BS后台管理'}></title>
    <{include file="public/header"}>
    <{include file="public/data_tables_css"}>

</head>
<body class="hold-transition sidebar-mini layout-fixed">
<!-- Site wrapper -->
<div class="wrapper">
    <!-- Navbar -->
    <{include file="public/navbar"}>
    <!-- /.navbar -->

    <!-- Main Sidebar Container -->
    <!--左侧菜单-->
    <{include file="public/sidebar"}>

    <!-- Content Wrapper. Contains page content -->
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1>管理员管理</h1>
                    </div>
                    <div class="col-sm-6">
                        <ol class="breadcrumb float-sm-right">
                            <li class="breadcrumb-item"><a href="<{:url('/admin/index/index')}>">首页</a></li>
                            <li class="breadcrumb-item"><a href="<{:url('/admin/auth.auser/index')}>">管理员 </a></li>
                        </ol>
                    </div>
                </div>
            </div><!-- /.container-fluid -->
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="container-fluid">


                <div class="card">
                    <div class="card-header">
                        <form action="<{:url()}>">
                            <div class="form-row ">
                                <div class="col-auto">
                                    <select name="status" class="form-control " >
                                        <option  value="">全部状态</option>
                                        <option <{if null !== $Request.param.status &&$Request.param.status=='1'}>selected<{/if}>  value="1">启用中</option>
                                        <option <{if null !== $Request.param.status &&$Request.param.status=='0'}>selected<{/if}> value="0">已禁用</option>
                                    </select>
                                </div>
                                <div class="col-auto">

                                    <select name="roleId" class="form-control" >
                                        <option value="">全部角色</option>
                                        <{if !empty($roles)}>
                                        <{foreach $roles as $v}>
                                        <option <{if !empty($Request.param.roleId)&&$Request.param.roleId==$v.id}>selected<{/if}>   value ="<{$v.id}>"><{$v.name}></option>
                                        <{/foreach}>
                                        <{else}>
                                        <optgroup label="未设置角色"></optgroup>
                                        <{/if}>
                                    </select>
                                </div>
                                <div class="col-auto">

                                    <input name="keyword" type="text"  class="form-control " placeholder="登录账号搜索" value="<{$Request.param.keyword?$Request.param.keyword:''}>">
                                </div>

                                <div class="col-auto">
                                    <button type="submit" class="btn btn-primary mb-2 "><i class="fas fa-search"></i></button>
                                    <a  onclick="location.replace('index.html')"  class="btn btn-default mb-2 bs-left-30" title="重置"><i class="fas fa-history"></i></a>
                                </div>
                            </div>
                        </form>
                    </div>
                    <!-- /.card-header -->
                    <div class="card-body">
                        <a class="btn btn-success btn-sm add-data" href="<{:url('/admin/auth.auser/form')}>">新增</a>
                        <table id="my_table" class="table table-bordered table-striped">
                            <thead>
                            <tr>
                                <th>#</th>
                                <th>昵称</th>
                                <th>登录账号</th>
                                <th>角色</th>
                                <th>状态</th>
                                <th>登录次数</th>
                                <th>时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <{if !empty($data)}>
                            <{foreach $data as $item}>
                            <tr>
                                <td><{$item.id}></td>
                                <td><{$item.user_name}></td>
                                <td><{$item.account}></td>
                                <td><{$item.roleName}></td>
                                <td>
                                    <{if $item.status=='1'}>
                                    <span class="alert-success">启用中</span>
                                    <{else}>
                                    <span class="alert-warning">已禁用</span>
                                    <{/if}>
                                </td>
                                <td><a title="查看登录记录" href="<{:url('login_log',['keyword'=>$item.uid])}>"><{$item.loginCount}></a></td>
                                <td>
                                    添加：<{$item.add_time|date="Y-m-d H:i:s",###}> <br>
                                    更新：<{$item.up_time|date="Y-m-d H:i:s",###}>
                                </td>
                                <td>



                                    <a class="btn btn-success btn-sm" href="<{:url('/admin/auth.auser/form',['id'=>$item.id])}>" title="查看编辑"><i class="fas fa-edit"></i></a>
                                    <{if $item.id <> '1'}>
                                    <span class="btn btn-danger btn-sm del-data bs-left-10" data-id="<{$item.id}>" title="删除"><i class="fas fa-trash"></i></span>
                                    <{/if}>
                                </td>

                            </tr>
                            <{/foreach}>
                            <{/if}>



                            </tbody>

                        </table>
                    </div>
                    <div class="card-footer">
                        <{$page?$page->render():''}>
                    </div>
                    <!-- /.card-body -->
                </div>
            </div>
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->

    <{include file="public/copyright"}>


</div>
<!-- ./wrapper -->

<{include file="public/footer"}>
<!-- DataTables  & Plugins -->
<{include file="public/data_tables"}>
<script>
    $(function () {
        $(".del-data").on('click',function () {
            var id = $(this).data('id')
            var obj = $(this);
           layer.confirm('确定要删除吗，不可恢复哦',{title:0},function () {
               sendData("<{:url('/admin/auth.auser/action')}>",{id:id,ac:'del'},function (res) {
                   if(res.code==0){
                       $(obj).parent('td').parent('tr').remove();
                   }
               })
           })
        });
        $("#my_table").DataTable({
            "ordering": false,//禁用排序
            "responsive": true,
            "lengthChange": false,
            "autoWidth": false,
            //"buttons": ["copy", "csv", "excel", "pdf", "print", "colvis"],
           // "pageLength": 10,         //初始化显示几条数据
            //serverSide: true, // use local process instead of server
           // bFilter: true, // show top right search input box.
            bPaginate: false,//是否开启分页
            //iDisplayLength: 10, //默认显示的记录数
            bInfo: false,//是否显示页脚信息，DataTables插件左下角显示记录数
        }).buttons().container().appendTo('#my_table_wrapper .col-md-6:eq(0)');

    });
</script>
</body>
</html>
